package com.fs.cv.controller;

import com.fs.cv.pojo.pojodao.Classroom;
import com.fs.cv.pojo.pojoview.ClassroomRecordInfo;
import com.fs.cv.service.ClassroomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @工程名: SSM项目
 * @描述：
 * @作者: 小梁子
 * @创建时间: 2020-10-10 09:59
 **/

@RequestMapping("/classroomInfo")
@Controller
public class ClassroomController {

    @Autowired
    private ClassroomInfoService classroomInfoService;


    //查询所有教室信息
    @RequestMapping("getClassroomInfo")
    @ResponseBody
    public Map<String,Object> getClassroomInfo(){
        Map<String,Object> result = new HashMap<>();
        result.put("code",0);
        result.put("classroomes",classroomInfoService.getAllClassroomInfo());
        return result;
    }

    //添加一个教室信息
    @RequestMapping("/addClassroomInfo")
    @ResponseBody
    public Map<String,Object> addClassroomInfo(Classroom classroomInfo){
        System.out.println(classroomInfo);
        Map<String,Object> result=new HashMap<>();
        result.put("code",classroomInfoService.addOneClassroom(classroomInfo));
        return result;
    }

    //通过ID获取当前教室信息
    @RequestMapping("/getOneClassroomInfoById")
    @ResponseBody
    public Map<String,Object> getOneClassroomInfoById(Integer classroomId){
        System.out.println(classroomId);
        Map<String,Object> result=new HashMap<>();
        result.put("classroom",classroomInfoService.getOneClassroomInfo(classroomId));
        result.put("code",0);
        return result;
    }

    //修改当前教室信息
    @RequestMapping("/editclassroomInfo")
    @ResponseBody
    public Map<String,Object> editclassroomInfo(Classroom classroom){
        System.out.println(classroom);
        Map<String,Object> result=new HashMap<>();
        result.put("code",classroomInfoService.editClassroomInfo(classroom));
        return result;
    }

    //修改当前教室信息
    @RequestMapping("/deletedOneClassroomInfo")
    @ResponseBody
    public Map<String,Object> deletedOneClassroomInfo(Integer classroomId){
        System.out.println(classroomId);
        Map<String,Object> result=new HashMap<>();
        result.put("code",classroomInfoService.deleteOneClassroomInfo(classroomId));
        return result;
    }

}
